/**
 * @name 简单状态管理模式-页面级状态
 * @author wangsongle
 * @description 2021/10/26
 * @copyright http://songle.wang
 * @version 1.0
 */

export default {
    debug: true,
    state: {
        //档案目录
        catalog: {
            type: Object,
            default: {}
        },
        homerole: [
            {roleId: 0,roleName: '户主'},
            {roleId: 1,roleName: '丈夫'},
            {roleId: 2,roleName: '妻子'},
            {roleId: 3,roleName: '长女'},
            {roleId: 4,roleName: '次女'},
            {roleId: 5,roleName: '三女'},
            {roleId: 6,roleName: '长子'},
            {roleId: 7,roleName: '次子'},
            {roleId: 8,roleName: '三子'},
            {roleId: 9,roleName: '四子'},
            {roleId: 10,roleName: '孙子'},
            {roleId: 11,roleName: '孙女'},
            {roleId: 12,roleName: '外孙子'},
            {roleId: 13,roleName: '外孙女'},
        ],
        crumbs: {
            type: Object,
            default: {}
        }
    },
    setCatalog(code,key,value){
        if(!this.state.catalog[code]){
            this.state.catalog[code] = {}
        }
        this.state.catalog[code][key] = value
        if(this.debug) console.log('[page]:setCatalog -> ',code,key,value)
    },
    getCatalog(code,key){
        if(this.state.catalog[code]){
            return this.state.catalog[code][key]
        }
        return null
    },
    setCrumbs(key,value){
        this.state.crumbs[key] = value
        if(this.debug) console.log('[page]:setCrumbs -> ',key,value)
    },
    getCrumbs(key){
        return this.state.crumbs[key]
    },
    getHomerole() {
        return this.state.homerole
    },
    clear(){
        for(let key in this.state.catalog){
            delete this.state.catalog[key]
        }
        for(let key in this.state.crumbs){
            delete this.state.crumbs[key]
        }
    }
}